package com.xcdh.trading.entity;

import com.baomidou.mybatisplus.annotation.*;
import lombok.Data;
import java.math.BigDecimal;
import java.util.Date;

@Data
@TableName("stock_info")
public class StockInfo {
    @TableId(value = "ts_code", type = IdType.INPUT)
    private String tsCode;

    private String name;
    private BigDecimal price;
    private BigDecimal pctChg;
    private BigDecimal pctChgSum;
    @OrderBy(sort = 2)
    private Integer nums;

    private Integer dNums = 0;

    private Integer upNum;
    private Integer downNum;
    @OrderBy(sort = 1)
    private String tradeDate;
    //D跌停U涨停Z炸板
    @TableField("`limit`")
    private String  limit ;
    @TableField(updateStrategy = FieldStrategy.IGNORED)
    private String  upStat ;
    //炸板次数
    private Integer openNum ;
    @TableField(updateStrategy = FieldStrategy.IGNORED)
    private String firstTime ;
    @TableField(updateStrategy = FieldStrategy.IGNORED)
    private String lastTime ;
    @TableField(updateStrategy = FieldStrategy.IGNORED)
    private Float fdAmount ;
    //板上成交金额
    @TableField(updateStrategy = FieldStrategy.IGNORED)
    private Float limitAmount ;
    //所属行业
    private String industry ;

    @TableField( value = "turnover_rate")
    @OrderBy(sort = 4)
    private Float turnoverRate ;
    @TableField( value = "volume_ratio")
    private Float volumeRatio = 0F;

    @TableField( value = "hot_amount")
    public Float hotAmount ;
    @TableField( value = "big_amount")
    public Float bigAmount ;

    @TableField( value = "small_amount")
    public Float smallAmount ;
    /*涨跌比例*/
    @TableField( value = "zd_ratio")
    private Integer zdRatio ;
    @TableField( value = "zdf_ratio")
    @OrderBy(sort = 5)
    private Integer  zdfRatio ;

    @TableField( value = "zf_num")
    private Integer  zfNum ;

    @TableField( value = "df_num")
    private Integer  dfNum ;

    @TableField( value = "zdf_num")
    private Integer  zdfNum ;
    public BigDecimal getShowPrice(){
        if(pctChg.compareTo(BigDecimal.ZERO) < 0){
            return price.multiply(BigDecimal.valueOf(-1)) ;
        }
        return price ;
    }

    public String getZdNumStr(){
        return String.format("%s/%s" ,upNum , downNum ) ;
    }
    public String getZdfNumStr(){
        return String.format("%s#%s/%s" , zdfRatio ,zfNum , dfNum ) ;
    }


}
